﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StoragePeriod.Common;
using StoragePeriod.Data;
using StoragePeriod.Web.Common;

namespace StoragePeriod.Web.StorageForecast
{
    public partial class StorageAnalysis : SecurityPage
    {
        #region
        public override string PrivCode()
        {
            return "c84adecf893b0391";
        }
        #endregion

        private void DropBandingSearch()
        {
            List<OperationTeam> OperationList = OperationTeam.Where("ParentId=@0", 0).OrderByDescending(p => p.id).ToList();
            this.Drop_OperationSearch.DataSource = OperationList;
            this.Drop_OperationSearch.DataValueField = "id";
            this.Drop_OperationSearch.DataTextField = "OTName";
            this.Drop_OperationSearch.DataBind();
            this.Drop_OperationSearch.Items.Insert(0, new ListItem("全部", "-1"));
            this.Drop_OperationSearch_SelectedIndexChanged(null, null);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.LeftTree.SelectedChanging += new UserControls.MaterialTree.TreeEventDelegate(LeftTree_SelectedChanging);
            if (IsPostBack) return;
            DropBandingSearch();
        }

        protected void LeftTree_SelectedChanging(Dictionary<string, string> dic)
        {
            UtilityUI.Load(this.UpdatePanel1, "TreeRadioOrMulti();");
        }

        protected void Drop_OperationSearch_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.Drop_OperationSearch.SelectedItem != null)
            {
                int ParentId = Convert.ToInt32(this.Drop_OperationSearch.SelectedValue);
                List<OperationTeam> TeamList;
                if (ParentId == -1)
                {
                    TeamList = new List<OperationTeam>();
                    TeamList.Add(new OperationTeam() { id = -1, OTName = "全部" });
                }
                else
                {
                    TeamList = OperationTeam.Where("ParentId=@0", ParentId).ToList();
                }
                this.Drop_TeamSearch.DataSource = TeamList;
                this.Drop_TeamSearch.DataValueField = "id";
                this.Drop_TeamSearch.DataTextField = "OTName";
                this.Drop_TeamSearch.DataBind();
            }
        }
    }
}